﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using HotelUI.Models;
using IHodelBll;
using Model;
using HodelBll;

namespace HotelUI.Controllers
{
    public class RoomController : Controller
    {
        private readonly ILogger<RoomsModel> _logger;
        IRoomsBLL _roombll;

        public RoomController (ILogger<RoomsModel> logger, IRoomsBLL roombll)
        {
            _logger = logger;
            _roombll = roombll;
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Room()
        {
            return View();
        }



        [HttpGet]
        public IActionResult AddRooms()
        {
            return View();
        }
        /// <summary>
        /// 返回添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult AddRoomview()
        {
            return View();
        }
        /// <summary>
        /// 添加客房
        /// </summary>
        /// <param name="rooms"></param>
        /// <returns></returns>
        [HttpPost]
        public int AddRoom(RoomList list)
        {        
            return _roombll.AddRoom(list);
        }
        //
        /// <summary>
        /// 删除客房
        /// </summary>
        /// <param name="aid"></param>
        /// <returns></returns>
        public int DelRoom(int aid)
        {
            return _roombll.DelRoom(aid);
        }

        /// <summary>
        /// 修改返回视图
        /// </summary>
        /// <returns></returns>
        public IActionResult UptRoomView()
        {
            return View();
        }
        /// <summary>
        /// 修改客房
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int UptRoom(RoomList m)
        {
            return _roombll.UptRoom(m);
        }

        /// <summary>
        /// 返回视图
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult RoomsShow()
        {
            return View();
        }
        /// <summary>
        /// 显示查询客房信息
        /// </summary>
        /// <returns></returns>     
        [HttpGet]
        public List<RoomsModel> RoomsModels(string name)
        {
            List<RoomsModel> list = _roombll.RoomModels();
            if (!string.IsNullOrEmpty(name))
            {
                list = list.Where(r => r.Rname.Contains(name)).ToList();
            }
            return list;
        }
        [HttpGet]
        public List<RoomType> RoomsType(string name)
        {
            List<RoomType> list = _roombll.RoomsType();
           
            return list;
        }



    }
}
